#include "seqlist.h"

seqlist * init_list(int cap)
{
    // 申请管理结构体
    seqlist *sqlist = malloc(sizeof(seqlist));
    if(sqlist == NULL)
    {
        perror("申请管理结构体失败");
        return NULL;
    }

    // 申请真正存储节点的顺序表空间
    sqlist->data = malloc(sizeof(student)*cap);
    if(sqlist->data == NULL)
    {
        perror("申请顺序表空间失败");
        free(sqlist);
        return NULL;
    }

    sqlist->capacity = cap;
    sqlist->len = 0;
    return sqlist;
}
bool is_full(seqlist *list)
{
    if(list->len>=list->capacity)
    return true;
}
bool add_list(const student *someone, seqlist *list)
{
    if(is_full(list))    
        return false;

    list->data[list->len] = *someone;
    list->len++;
    return true;
}

void list_for_each(seqlist *list)
{
//    if(list==NULL)
//         return;
    for(int i=0;i<list->len;i++)
    {
        printf("%d\t",list->data[i].age);
        printf("%s\t",list->data[i].name);
        printf("%f\t",list->data[i].score);
    } 
    printf("\n");
}
void sort_list(seqlist *sqlist);
{
    for(int j=0;j<sqlist->len;j++)
    {
        for(int i=0;i<sqlist->len;i++)
        {
            
        }
    }
}